home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 35 / Amiga Format AFCD35 (Issue 119, Jan 1999).iso / -in_the_mag- / reader_requests / fredobbutils / bbsrc / fb_bootintro.s < prev    next >
Text File  |  1998-11-06  |  7KB  |  416 lines

  1. *** BOOTBLOCK INTRO numéro 1 ***
  2. * Auteur: Frédéric Bassaler (mai 95)
  3. * Une petite bootblock intro...
  4. * - Utilisation de rasters, de sprites & de bitplanes
  5. * - Routine de ScrollText
  6.  
  7. * My 1st Bootblock Intro... pretty lame :-)
  8.  
  9.     incdir    asm:/Include/
  10.     include    equ.s
  11.     include    exec/types.i
  12.     include    graphics/text.i
  13.     include    graphics/gfx.i
  14.     include    graphics/rastport.i
  15.  
  16.     rsreset
  17. chipbuf    rs.l    1
  18. gfxbase    rs.l    1
  19. olddma    rs.w    1
  20. ;xstart    rs.w    1
  21. ystart    rs.w    1
  22. scrw    rs.w    1
  23. scrh    rs.w    1
  24. charw    rs.w    1
  25. charh    rs.w    1
  26. rast    rs.b    rp_SIZEOF
  27. bmap    rs.b    bm_SIZEOF
  28. VARSIZE    rs.w    0
  29.  
  30. WIDTH=330*1
  31. HEIGHT=266
  32. DEPTH=1
  33. PLANESIZE=((WIDTH/8)*HEIGHT)*DEPTH
  34.  
  35. COL0=$000
  36. COL1=$fff
  37.  
  38. SCROLLY=130
  39. SCROLLSPEED=2
  40.  
  41. ;MOUSE=0    ;pointeur souris ou non?
  42. ;DBUG=0
  43.  
  44. Start:
  45.     IFND    DBUG
  46.     dc.l    $444f5300
  47.     dc.b    "SUM!"
  48.     dc.l    $370
  49.     ENDC
  50. Main:
  51.     IFD    DBUG
  52.     move.l    4.w,a6
  53.     ENDC
  54.     movem.l    d0-a6,-(sp)
  55.     sub    #VARSIZE,sp    ;on utilise la pile comme base des variables
  56.     move.l    sp,a5        ;VarBase en a5
  57.  
  58.     move.l    $9c(a6),gfxbase(a5)    ;execbase->gfxbase
  59. * Allouer buffer pour les bitplanes & copperlist
  60.     move.l    #BUFSIZE,d0
  61.     move.l    #$10002,d1
  62.     jsr    AllocMem(a6)
  63.     move.l    d0,(a5)
  64.     beq.w    closegfx
  65.     move.l    d0,d4
  66.  
  67.     lea    rast(a5),a1
  68.     move.l    a1,-(sp)
  69.     move.l    gfxbase(a5),a6
  70.     jsr    InitRastPort(a6)
  71.  
  72.     lea    bmap(a5),a0
  73.     move.l    d4,bm_Planes(a0)    ;adresse des bitplanes
  74.     move.l    (sp)+,a1
  75.     move.l    a0,rp_BitMap(a1)
  76.     moveq    #DEPTH,d0
  77.     move    #WIDTH,d1
  78.     move    #HEIGHT,d2
  79.     movem    d1-d2,scrw(a5)
  80.     jsr    InitBitMap(a6)
  81.  
  82.     lea    topaz.textattr(pc),a0
  83.     move.l    154(a6),a1    ;gfxbase->default font
  84.     move.l    10(a1),(a0)    ;node name
  85.     jsr    OpenFont(a6)
  86.  
  87.     lea    rast(a5),a1
  88.     move.l    d0,rp_Font(a1)
  89.     move.l    d0,a0
  90.     move    tf_XSize(a0),charw(a5)
  91.     move    tf_YSize(a0),charh(a5)
  92.     jsr    CloseFont(a6)
  93.  
  94. ;    lea    rast(a5),a1
  95. ;    moveq    #1,d0
  96. ;    jsr    SetAPen(a6)
  97.  
  98. ;    clr    xstart(a5)
  99.     move    #18,ystart(a5)
  100.     lea    texte(pc),a0
  101.     bsr.w    print
  102.  
  103. ;    move.l    4.w,a6
  104. ;    jsr    Forbid(a6)
  105.  
  106.     lea    $dff000,a4
  107.     move    $02(a4),olddma(a5)
  108.     or    #$8000,olddma(a5)
  109.     move    #$7fff,$96(a4)    ;dma off
  110.     lea    coplist(pc),a1
  111. * adresse des bitplanes
  112.     move.l    (a5),d0
  113.     move.l    d0,a2
  114.     move    d0,lo1-coplist(a1)
  115.     swap    d0
  116.     move    d0,hi1-coplist(a1)
  117. * copier données Sprite en CHIP MEM
  118. * et initialiser ptrs Sprite
  119.     IFD    MOUSE
  120.     lea    SpriteData(pc),a0
  121.     lea    sprdata(a2),a1
  122.     move.l    a1,d0
  123.     moveq    #(SPRSIZE/4)-1,d1
  124. .copspr    move.l    (a0)+,(a1)+
  125.     dbf    d1,.copspr
  126.     lea    coplist(pc),a1
  127.     move    d0,sprlo-coplist(a1)
  128.     swap    d0
  129.     move    d0,sprhi-coplist(a1)
  130.     ENDIF
  131. * copier copperlist en CHIP MEM
  132.     lea    PLANESIZE(a2),a2
  133.     move.l    a2,a3
  134.     moveq    #((COPSIZE-DEGSIZE)/4)-1,d0
  135. .copy
  136.     move.l    (a1)+,(a2)+
  137.     dbf    d0,.copy
  138. * construction d'un dégradé avec le copper
  139. DEGSIZE=4096*2
  140. COL=$000
  141. INC=$101
  142. .deg
  143.     moveq    #22,d0        ;YStart
  144.     move    #COL,d1
  145.     move    #INC,d2
  146.     moveq    #-2,d4
  147. .dg0
  148.     move    #$0180,(a2)+
  149.     move    d1,(a2)+
  150.     move    d1,d3
  151.     add    d2,d1
  152.     move    #$0182,(a2)+
  153.     neg    d3
  154.     sub    d2,d3
  155.     move    d3,(a2)+
  156. .dg1
  157.     move.b    d0,(a2)+
  158.     addq.b    #1,d0
  159.     move.b    #$0f,(a2)+
  160.     move    d4,(a2)+    ;$fffe (Wait)
  161.  
  162.     cmp.b    #255,d0
  163.     bcs.b    .dg0
  164.  
  165.     move.l    d4,(a2)        ;$ffff,$fffe = fin coplist
  166.  
  167.     move.l    a3,$80(a4)    ;start coplist
  168.     clr    $88(a4)
  169. * initialisation des canaux dma
  170.     IFD    MOUSE
  171.     move    #%1000001111100000,$96(a4)
  172.     ELSE
  173.     move    #%1000001111000000,$96(a4)
  174.     ENDC
  175.  
  176.     lea    scroll.txt(pc),a3
  177.     move    charw(a5),d7
  178.     lsr    #1,d7
  179. ;    moveq    #4,d7
  180.  
  181. .w    btst    #6,$bfe001
  182.     beq.s    .end
  183. .waitvbl
  184.     move.l    gfxbase(a5),a6
  185.     jsr    WaitTOF(a6)
  186.  
  187.     btst    #10,$dff016
  188.     beq.b    .stop
  189.     bsr.w    scroll
  190. .stop
  191. * réactualiser la position de Sprite
  192. * (pointeur de la souris)
  193.     IFD    MOUSE
  194. .getmousecoord
  195.     move    $a(a4),d0    ;joy0dat
  196.     move    d0,d1
  197.     and    #$ff,d0
  198.     lsr    #8,d1
  199.     add    #150,d0
  200.     add    #30,d1
  201. .setspritecoord
  202.     move    d0,d3
  203.     and    #1,d3
  204.     lsr    #1,d0
  205.     move    d0,d2
  206.     and    #$ff,d2
  207.     move    d1,d0
  208.     add    #16,d0
  209.     rol    #8,d1
  210.     bcc.b    .noE8
  211.     bset    #2,d3
  212. .noE8    or    d1,d2
  213.     rol    #8,d0
  214.     bcc.b    .noL8
  215.     bset    #1,d3
  216. .noL8    or    d0,d3
  217.     move.l    (a5),a0
  218.     movem    d2-d3,sprdata(a0)
  219.     ENDIF
  220.  
  221.     bra.s    .w
  222. .end
  223.  
  224. Restore
  225. ;    move    #$7fff,$96(a4)
  226.     move.l    4.w,a6
  227.     move.l    $9c(a6),a0        ;execbase->gfxbase
  228.     move.l    38(a0),$80(a4)        ;coplist système
  229.     clr    $88(a4)            ;restore coplist
  230.     move    olddma(a5),$96(a4)    ;restore DMA
  231. .free
  232.     move.l    (a5),a1
  233.     move.l    #BUFSIZE,d0
  234.     jsr    FreeMem(a6)
  235. ;    jsr    Permit(a6)
  236. closegfx
  237. fin
  238.     add    #VARSIZE,sp    ;restitue la pile
  239.     movem.l    (sp)+,d0-a6
  240. BootUp:
  241.     lea    dosname(pc),a1
  242. ;    move.l    #' dos',(a1)
  243. ;    addq.l    #1,a1
  244.     jsr    FindResident(a6)
  245.     move.l    d0,a0
  246.     move.l    22(a0),a0
  247.     moveq    #0,d0
  248.     rts
  249.  
  250. *** Afficher les lignes de titre (avec centrage du texte)
  251. * <-- a0: adr texte (terminé par 0)
  252. print
  253.     movem.l    d0-a6,-(sp)
  254.     moveq    #0,d0
  255.     move    ystart(a5),d1
  256. ;    movem    xstart(a5),d0-d1
  257. ;    move.l    gfxbase(a5),a6
  258.     lea    rast(a5),a3
  259. .readchars
  260.     moveq    #0,d4
  261.     move.b    (a0)+,d4
  262.     beq.b    .f
  263.     subq    #1,d4
  264.     move    scrw(a5),d0
  265.     move.l    d4,d3
  266.     mulu    charw(a5),d3
  267.     sub.l    d3,d0
  268.     asr.l    #1,d0
  269.     bsr.b    .pr
  270.     add.l    d4,a0
  271. ;    move    xstart(a5),d0
  272.     move    charh(a5),d2
  273.     asl    #1,d2
  274.     add    d2,d1
  275.     bra.b    .readchars
  276. .f
  277. ;    movem    d0-d1,xstart(a5)
  278.     movem.l    (sp)+,d0-a6
  279.     rts
  280. .pr
  281.     movem.l    a0/d0/d1,-(sp)
  282.     move.l    a3,a1
  283.     jsr    Move(a6)
  284.     movem.l    (sp)+,a0/d0/d1
  285.     movem.l    a0/d0/d1,-(sp)
  286.     move.l    a3,a1
  287.     move.l    d4,d0
  288.     jsr    Text(a6)
  289.     movem.l    (sp)+,a0/d0/d1
  290.     rts
  291.  
  292. *** Effacer l'écran
  293. ;ClrSc
  294. ;    movem.l    d0-a6,-(sp)
  295. ;    lea    rast(a5),a1
  296. ;    move.l    gfxbase(a5),a6
  297. ;    jsr    ClearScreen(a6)
  298. ;    movem.l    (sp)+,d0-a6
  299. ;    rts
  300.  
  301. *** Routine de Scrolling de texte
  302. scroll:
  303.     lea    rast(a5),a2
  304. .letter
  305.     move.b    (a3),d0
  306.     bne.b    .nxt
  307. .restart
  308.     lea    scroll.txt(pc),a3
  309. .nxt
  310.     subq    #1,d7
  311.     bne.b    .sc
  312.  
  313.     move.l    a2,a1
  314.     move    scrw(a5),d0
  315.     subq    #8,d0
  316.     move    #SCROLLY,d1
  317.     jsr    Move(a6)
  318.     move.l    a2,a1
  319.     move.l    a3,a0
  320.     moveq    #1,d0
  321.     jsr    Text(a6)
  322.  
  323.     addq.l    #1,a3
  324. ;    moveq    #4,d7
  325.     move    charw(a5),d7
  326.     lsr    #1,d7
  327. .sc
  328.     move.l    a2,a1
  329.     moveq    #SCROLLSPEED,d0    ;delta x
  330.     moveq    #0,d1        ;delta y
  331.     moveq    #0,d2        ;x1
  332.     move    #SCROLLY,d3    ;y1
  333.     move    d3,d5
  334.     sub    charh(a5),d3
  335.     move    scrw(a5),d4    ;x2
  336.     addq    #8,d4
  337.     add    charh(a5),d5    ;y2
  338.     jmp    ScrollRaster(a6)
  339.  
  340. *** DATA
  341. LORES=$1200
  342. HIRES=LORES!$8000
  343. LACE=4
  344.  
  345. coplist:
  346.  DC.w $0100,LORES
  347.  dc.w $0102,$0000
  348.  dc.w $0108,$0000
  349.  dc.w $008E,$2c70    $2981
  350.  DC.w $0090,$2cc1    $29c1
  351.  dc.w $0092,$0038
  352.  DC.w $0094,$00d5
  353. ; DC.w $0180,COL0
  354. ; dc.w $0182,COL1
  355.  dc.w $00e0
  356. hi1:dc.w 0
  357.  dc.w $00e2
  358. lo1:dc.w 0
  359.     IFD    MOUSE
  360.  dc.w $0120
  361. sprhi:dc.w 0
  362.  dc.w $0122
  363. sprlo:dc.w 0
  364. * couleurs du ptr de la souris (sprite)
  365.  dc.w $01a2,$410    ;color17
  366.  dc.w $01a4,$720    ;color18
  367.  dc.w $01a6,$f30    ;color19
  368. ; dc.w $104,$0000
  369.     ENDIF
  370. ; dc.w $FFFF,$FFFE    ;fin de la liste copper
  371. COPSIZE=*-coplist+DEGSIZE
  372.  
  373. spritedata:
  374.     IFD    MOUSE
  375.     incdir    SrcII:mouseptr/
  376.     incbin    handptr.dat
  377.     ENDIF
  378. SPRSIZE=*-spritedata
  379. SprData=PLANESIZE+COPSIZE
  380.  
  381. BUFSIZE=PLANESIZE+COPSIZE+SPRSIZE
  382.  
  383. topaz.textattr:
  384.     dc.l    0
  385.     dc.w    8
  386.     dc.b    0,0
  387.     even
  388. ;gfxname dc.b "grap"
  389. dosname dc.b "dos.library",0
  390.  
  391. texte
  392. l0
  393. ; dc.b l1-l0," "
  394. l1
  395.  DC.B l2-l1,"-*- BootIntro #1 -*-"
  396. l2
  397.  dc.b l3-l2,"Coded by Frédo !"
  398. l3
  399. ; dc.b l4-l3,"**************"
  400. l4
  401. ; DC.B l5-l4," "
  402. l5
  403. ; dc.b l6-l5," "
  404. l6
  405.  dc.b 0
  406. scroll.txt
  407.  dc.b "This intro uses rasters, bitplanes..."
  408.  dc.b " and is 100% system-friendly "
  409.  dc.b " -> optimized code!"
  410.  dc.b " You can put more than 200 bytes of scrolltext!!"
  411.  dc.b " -*- "
  412.  dc.b 0
  413.  
  414. End:
  415.     dcb.b    512*2,0
  416.